package org.example.runafterstart.commandLineRunners;

import lombok.extern.slf4j.Slf4j;
import org.example.runafterstart.service.TestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Description:
 */

@Component
@Slf4j
// 通过order指定执行顺序，数字越小先执行
@Order(1)
public class CommandLineRunnerImpl implements CommandLineRunner {
    @Autowired
    private TestServiceImpl testService;

    @Override
    public void run(String... args) throws Exception {
        log.info("CommandLineRunner 在启动后执行..........");
        testService.save();
    }
}
